/**
 * amis v6.13.0
 * build time: 2025-08-12
 * Copyright 2018-2025 baidu
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _withBadge = require('amis-ui/lib/components/withBadge');
var _Avatar = require('amis-ui/lib/components/Avatar');
var tslib = require('tslib');
var React = require('react');
var amisCore = require('amis-core');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _withBadge__default = /*#__PURE__*/_interopDefaultLegacy(_withBadge);
var _Avatar__default = /*#__PURE__*/_interopDefaultLegacy(_Avatar);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;


;var AvatarField = /** @class */function (_super) {
  tslib.__extends(AvatarField, _super);
  function AvatarField() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  AvatarField.prototype.handleClick = function (e) {
    var _a = this.props,
      dispatchEvent = _a.dispatchEvent,
      data = _a.data;
    dispatchEvent(e, data);
  };
  AvatarField.prototype.handleMouseEnter = function (e) {
    var _a = this.props,
      dispatchEvent = _a.dispatchEvent,
      data = _a.data;
    dispatchEvent(e, data);
  };
  AvatarField.prototype.handleMouseLeave = function (e) {
    var _a = this.props,
      dispatchEvent = _a.dispatchEvent,
      data = _a.data;
    dispatchEvent(e, data);
  };
  AvatarField.prototype.render = function () {
    var _a = this.props,
      _b = _a.style,
      style = _b === void 0 ? {} : _b,
      className = _a.className,
      cx = _a.classnames,
      src = _a.src,
      defaultAvatar = _a.defaultAvatar,
      _c = _a.icon,
      icon = _c === void 0 ? 'fa fa-user' : _c,
      fit = _a.fit,
      shape = _a.shape,
      size = _a.size,
      text = _a.text,
      gap = _a.gap,
      alt = _a.alt,
      draggable = _a.draggable,
      crossOrigin = _a.crossOrigin,
      onError = _a.onError,
      data = _a.data;
    var errHandler = function () {
      return false;
    };
    if (typeof onError === 'string') {
      try {
        errHandler = new Function('event', onError);
      } catch (e) {
        console.warn(onError, e);
      }
    }
    if (amisCore.isPureVariable(src)) {
      src = amisCore.resolveVariableAndFilter(src, data, '| raw');
    }
    if (amisCore.isPureVariable(text)) {
      text = amisCore.resolveVariableAndFilter(text, data);
    }
    if (amisCore.isPureVariable(icon)) {
      icon = amisCore.resolveVariableAndFilter(icon, data);
    }
    return _J$X_(_Avatar__default["default"], {
      style: style,
      className: className,
      classnames: cx,
      src: src || defaultAvatar,
      icon: icon,
      fit: fit,
      shape: shape,
      size: size,
      text: text,
      gap: gap,
      alt: alt,
      draggable: draggable,
      crossOrigin: crossOrigin,
      onError: errHandler,
      onClick: this.handleClick,
      onMouseEnter: this.handleMouseEnter,
      onMouseLeave: this.handleMouseLeave
    });
  };
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", void 0)], AvatarField.prototype, "handleClick", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", void 0)], AvatarField.prototype, "handleMouseEnter", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", void 0)], AvatarField.prototype, "handleMouseLeave", null);
  return AvatarField;
}(React__default["default"].Component);
var AvatarFieldRenderer = /** @class */function (_super) {
  tslib.__extends(AvatarFieldRenderer, _super);
  function AvatarFieldRenderer() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  AvatarFieldRenderer = tslib.__decorate([amisCore.Renderer({
    type: 'avatar'
  })
  // @ts-ignore
  , _withBadge__default["default"]], AvatarFieldRenderer);
  return AvatarFieldRenderer;
}(AvatarField);

exports.AvatarField = AvatarField;
exports.AvatarFieldRenderer = AvatarFieldRenderer;
